#pragma once

#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <sys/types.h>
#include <sys/socket.h>

#include <jsoncpp/json/json.h>
#include "Util.hpp"

// http协议
namespace protocol_ns
{
#define SEP " "
#define SEP_LEN strlen(SEP) // 绝对不能写成sizeof
#define HEADER_SEP "\r\n"
#define HEADER_SEP_LEN strlen("\r\n")

    std::string AddHeader(const std::string &str)
    {
        std::string head = "HTTP/1.1 200 OK\n";
        return head+str;
    }

    std::string RemoveHeader(const std::string &str, int len)
    {
        //去掉http协议的响应头
    }

    // const &: 输入
    // *: 输出
    // &: 输入输出
    int ParsePackage(std::string &inbuffer, std::string *package)
    {
        //简单起见，直接把inbuffer报文拿给上层
        int size = inbuffer.size();
        *package = inbuffer;

        inbuffer.erase(0,size);
        return size;
    }
}